const hapiPagination = require('hapi-pagination');

const options = {
  query: {
    // ... 此处篇幅考虑省略 query 入参配置代码，参看章节  github 案例
  },
  meta: {
    name: 'metaData',
    // ... 此处篇幅考虑省略 meta 的相关配置代码，参看章节  github 案例
    location: 'body',
    successStatusCode:200,
    count: {
      active: true,
      name: 'count'
    },

    totalCount: {
      active: true,
      name: 'totalCount'
    },
    pageCount: {
      active: true,
      name: 'pageCount'
    },
    self: {
      active: true,
      name: 'self'
    },
    previous: {
      active: true,
      name: 'previous'
    },
    next: {
      active: true,
      name: 'next'
    },
    hasNext: {
      active: false,
      name: 'hasNext'
    },
    hasPrevious: {
      active: false,
      name: 'hasPrevious'
    },
    first: {
      active: false,
      name: 'first'
    },
    last: {
      active: false,
      name: 'last'
    },
    page: {
      active: false,
      // name == default.query.page.name
    },
    limit: {
      active: false
      // name == default.query.limit.name
    }
  },
  results: {
    name: 'data',
  },
  reply: {
    paginate: 'paginate',
    // results: {
    //      name: 'data'
    //    },
    //    totalCount:{
    //      name: 'count'
    //    }

  },
  routes: {
    include: [
      '/shops' // 店铺列表支持分页特性
    ],
    exclude: []
  }
}

module.exports = {
  plugin: hapiPagination,
  options: options,
}
